home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DJGPP / CBGRX103.ZIP / contrib / libgrx / src / phbitblt.c < prev    next >
Text File  |  1993-12-06  |  3KB  |  88 lines

  1. /**
  2.  ** PHBITBLT.C
  3.  **
  4.  **  Copyright (C) 1992, Csaba Biegl
  5.  **    820 Stirrup Dr, Nashville, TN, 37221
  6.  **    csaba@vuse.vanderbilt.edu
  7.  **
  8.  **  This file is distributed under the terms listed in the document
  9.  **  "copying.cb", available from the author at the address above.
  10.  **  A copy of "copying.cb" should accompany this file; if not, a copy
  11.  **  should be available from where this file was obtained.  This file
  12.  **  may not be distributed without a verbatim copy of "copying.cb".
  13.  **  You should also have received a copy of the GNU General Public
  14.  **  License along with this program (it is in the file "copying");
  15.  **  if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  16.  **  Cambridge, MA 02139, USA.
  17.  **
  18.  **  This program is distributed in the hope that it will be useful,
  19.  **  but WITHOUT ANY WARRANTY; without even the implied warranty of
  20.  **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21.  **  GNU General Public License for more details.
  22.  **/
  23.  
  24. #include "p16.h"
  25. #include "memcopy.h"
  26. #include "gmalloc.h"
  27.  
  28. void _GrPHPixCopy(GC *dst,long daddr,GC *src,long saddr,int w,int h,int op)
  29. {
  30.     pixptr dstp = P_ADDRESS(dst,daddr);
  31.     pixptr srcp = P_ADDRESS(src,saddr);
  32.     pixptr temp;
  33.     int wbytes = (w << 1);
  34.     int doff = dst->gc_lineoffset - wbytes;
  35.     int soff = src->gc_lineoffset - wbytes;
  36.     int reverse = FALSE;
  37.  
  38.     if((w <= 0) || (h <= 0)) return;
  39.     op = C_OPER(op);
  40.     _ClrDir();
  41.     if((dst->gc_baseaddr == src->gc_baseaddr) && (daddr > saddr)) {
  42.         dstp = (pixptr)((long)dstp + (h * dst->gc_lineoffset) - doff - 2);
  43.         srcp = (pixptr)((long)srcp + (h * src->gc_lineoffset) - soff - 2);
  44.         doff = (-doff);
  45.         soff = (-soff);
  46.         reverse = TRUE;
  47.         _SetDir();
  48.     }
  49.     if(dst->gc_onscreen && src->gc_onscreen && _GrBigFrameBuffer) {
  50.         if(_GrCanBcopyInBlit && (op == C_SET)) {
  51.         dstp = (pixptr)((long)dstp + _GrWrOnlyOffset);
  52.         srcp = (pixptr)((long)srcp + _GrRdOnlyOffset);
  53.         }
  54.         else {
  55.         temp = (pixptr)_GrGetTempBuffer(wbytes + 2);
  56.         if(temp == (pixptr)NULL) return;
  57.         if(reverse) { temp += w; wbytes = (-wbytes); }
  58.         doff += wbytes;
  59.         soff += wbytes;
  60.         _SaveDS();
  61.         while(--h >= 0) {
  62.             _RowCpyW(RB,temp,srcp,w);
  63.             switch(op) {
  64.             case C_XOR: _RowCpyXorW(WBX,dstp,temp,w); break;
  65.             case C_OR:  _RowCpyOrW(WBO,dstp,temp,w);  break;
  66.             case C_AND: _RowCpyAndW(WBA,dstp,temp,w); break;
  67.             default:    _RowCpyW(WB,dstp,temp,w);      break;
  68.             }
  69.             dstp = (pixptr)((long)dstp + doff);
  70.             srcp = (pixptr)((long)srcp + soff);
  71.         }
  72.         _RestoreDS();
  73.         _ClrDir();
  74.         return;
  75.         }
  76.     }
  77.     _SaveDS();
  78.     switch(op) {
  79.         case C_XOR: _BlkCpyXorW(CWX,dstp,doff,srcp,soff,w,h); break;
  80.         case C_OR:  _BlkCpyOrW(CWO,dstp,doff,srcp,soff,w,h);  break;
  81.         case C_AND: _BlkCpyAndW(CWA,dstp,doff,srcp,soff,w,h); break;
  82.         default:    _BlkCpyW(CW,dstp,doff,srcp,soff,w,h);      break;
  83.     }
  84.     _RestoreDS();
  85.     _ClrDir();
  86. }
  87.  
  88.